package com.zzy.bridge;

import com.zzy.pojo.UserInfo;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: zzy
 * @CreateTime: 2024-09-30
 * @Description: 抽象类注册登录组件
 * @Version: 1.0
 */
public abstract class AbstractRegisterLoginComponent {

    protected RegisterLoginFuncInterface funcInterface;

    protected AbstractRegisterLoginComponent(RegisterLoginFuncInterface funcInterface) {
        validate(funcInterface);
        this.funcInterface = funcInterface;
    }

    private void validate(RegisterLoginFuncInterface funcInterface) {
        if(!(funcInterface instanceof RegisterLoginFuncInterface)) {
            throw new UnsupportedOperationException("Invalid FuncInterface!");
        }
    }

    public abstract String login(String userName, String password);

    public abstract String register(UserInfo userInfo);

    protected abstract boolean checkUserExist(String userName);

    public abstract String login3rd(HttpServletRequest request);
}
